package org.sczfdf.conf;

import org.sczfdf.utils.PropertiesUtil;

import java.io.File;

import static org.sczfdf.constants.Constant.LOG_FILE;
import static org.sczfdf.constants.Constant.LOG_FILE_LAZY;
import static org.sczfdf.constants.Constant.LOG_FILE_LEVEL;

/**
 * @author Created by cgb
 * @date 2023/1/31
 */
public class LogConf {
    private static final LogConf LOG_CONF = new LogConf();

    public static LogConf get() {
        return LOG_CONF;
    }

    private String logFile;
    private String logFileLevel;
    private boolean logFileLazy;

    private LogConf() {
        logFile = PropertiesUtil.getConf(LOG_FILE).trim();
        logFileLevel = PropertiesUtil.getConf(LOG_FILE_LEVEL);
        logFileLazy = Boolean.parseBoolean(PropertiesUtil.getConf(LOG_FILE_LAZY));

        if (logFile.startsWith("/") || logFile.startsWith("\\")) {
            logFile = System.getProperty("user.dir") + File.separator + logFile;
        }
    }

    public String getLogFile() {
        return logFile;
    }

    public void setLogFile(String logFile) {
        this.logFile = logFile;
    }

    public String getLogFileLevel() {
        return logFileLevel;
    }

    public void setLogFileLevel(String logFileLevel) {
        this.logFileLevel = logFileLevel;
    }

    public boolean isLogFileLazy() {
        return logFileLazy;
    }

    public void setLogFileLazy(boolean logFileLazy) {
        this.logFileLazy = logFileLazy;
    }
}
